{include file="header.htm" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-20">
    {include file="bar.htm" /}
    <div class="flexigrid">
        <div class="mDiv pt0">
            <div class="ftitle">
                <div class="fbutton">
                    <a href="{:weapp_url('Coupons/Coupons/add')}">
                        <div class="add">
                            <span><i class="layui-icon layui-icon-addition"></i>新增优惠券</span>
                        </div>
                    </a>
                </div>
            </div>
            <form class="navbar-form form-inline" action="{:weapp_url('Coupons/Coupons/index')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" class="qsbox" placeholder="搜索相关数据...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="fa fa-search"></i>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                        </th>
                        <th abbr="ac_id" axis="col4">
                            <div class="text-l10">优惠券名称</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w80">
                            <div class="tc">优惠券类型</div>
                        </th>
                        <th axis="col6" class="w150">
                            <div class="tc">优惠规则</div>
                        </th>
                        <th axis="col1" class="w80">
                            <div class="tc">会员限制</div>
                        </th>
                        <th axis="col5" class="w100">
                            <div class="tc">库存数量</div>
                        </th>
                        <th axis="col5" class="w100">
                            <div class="tc">已领取数量</div>
                        </th>
                        <th axis="col5" class="w160">
                            <div class="tc">有效期</div>
                        </th>
                        <th axis="col5" class="w60">
                            <div class="tc">启用</div>
                        </th>
                        <th axis="col5" class="w120">
                            <div class="tc">操作</div>
                        </th>
                        <th axis="col5" class="w60">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                    {foreach name="list" item="vo" key="k" }
                    <tr>
                        <td class="sign">
                            <div class="w40 tc">
                                <input type="checkbox" name="ids[]" value="{$vo.coupon_id}">
                            </div>
                        </td>
                        <td style="width: 100%">
                            <div class="text-l10">
                                {$vo.coupon_name}
                            </div>
                        </td>
                        <td>
                            <div class="w80 tc">
                                {if condition='1 == $vo.coupon_type'}
                                全站通用
                                {elseif condition='2 == $vo.coupon_type' /}
                                指定商品
                                {elseif condition='3 == $vo.coupon_type' /}
                                指定分类
                                {/if}
                            </div>
                        </td>
                        <td>
                            <div class="w150 tc">
                                {eq name="$vo.coupon_form" value="1"}
                                满{$vo.conditions_use}减{$vo.coupon_price}
                                {else /}
                                {notempty name="$vo.conditions_use"}满{$vo.conditions_use}{else /}无门槛{/notempty}打{$vo.coupon_discount}折
                                {/eq}
                            </div>
                        </td>
                        <td>
                            <div class="w80 tc"> {notempty name="$vo.redeem_authority"}是{else /}否{/notempty} </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.coupon_stock}
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.geted|default=0}
                            </div>
                        </td>
                        <td>
                            <div class="w160 tc">
                                {$vo.start_date|MyDate='Y-m-d H:i:s',###} 至 <br>{$vo.end_date|MyDate='Y-m-d H:i:s',###}
                            </div>
                        </td>
                        <td>
                            <div class="w60 tc">
                                {eq name="$vo['status']" value='1'}
                                <span class="yes" onclick="changeTableVal('weapp_coupons', 'coupon_id', '{$vo.coupon_id}', 'status', this);"> <i class="fa fa-check-circle"></i>是</span>
                                {else /}
                                <span class="no" onclick="changeTableVal('weapp_coupons', 'coupon_id', '{$vo.coupon_id}', 'status', this);"> <i class="fa fa-ban"></i>否</span>
                                {/eq}
                            </div>
                        </td>
                        <td class="operation">
                            <div class="w120 tc">
                                {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                <a href=" {:weapp_url('Coupons/edit',array('id'=>$vo['coupon_id']))}" class="btn blue">
                                    编辑
                                </a>
                                {/eq}
                                {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                <i></i>
                                <a class="btn red" href="javascript:void(0);" data-url=" {:weapp_url('Coupons/del')}" data-id="{$vo.coupon_id}" onClick="delfun(this);">
                                    删除
                                </a>
                                {else /}
                                <i></i>
                                <a class="btn grey" href="javascript:void(0);" >
                                    删除
                                </a>
                                {/eq}
                            </div>
                        </td>
                        <td class="sort">
                            <div class="w60 tc">
                                {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                <input type="text" onchange="changeTableVal('shop_coupon', 'coupon_id', '{$vo.coupon_id}', 'sort_order' ,this);" size="4" value="{$vo.sort_order}" />
                                {else /}
                                {$vo.sort_order}
                                {/eq}
                            </div>
                        </td>
                    </tr>
                    {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" autocomplete="off" class="checkAll">
                </div>
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:weapp_url('Coupons/Coupons/del')}">
                        <div class="add">
                            <span>批量删除</span>
                        </div>
                    </a>
                </div>
                <div class="fbuttonr">
                    <div class="pages">
                       {$pageStr}
                    </div>
                </div>
                <div class="fbuttonr">
                    <div class="total">
                       <h5>共有{$pager->totalRows}条,每页显示
                            <select name="pagesize" style="width: 60px;" onchange="ey_selectPagesize(this);">
                                <option {if condition="$pager->listRows == 15"} selected {/if} value="15">15</option>
                                <option {if condition="$pager->listRows == 30"} selected {/if} value="30">30</option>
                                <option {if condition="$pager->listRows == 50"} selected {/if} value="50">50</option>
                                <option {if condition="$pager->listRows == 100"} selected {/if} value="100">100</option>
                                <option {if condition="$pager->listRows == 200"} selected {/if} value="200">200</option>
                                <!-- <option {if condition="$pager->listRows == 500"} selected {/if} value="500">500</option> -->
                            </select>
                       </h5>
                    </div>
                </div>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
        
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });
</script>
{include file="footer.htm" /}
